﻿namespace IntegrationTests
{
    using System;
    using System.Linq;
    using DirectoryServicesProtocolsExtensions.SearchRequest;

    public class MockFabrikamActiveDirectoryQueryPropertiesContainer : ILdapSearchRequestPropertiesContainer
    {
        private string searchBaseDN = "CN=administrator,CN=Users,DC=fabrikam,dc=com";
        private string searchFilter = "(objectClass=*)";
        private string[] attributesToLoad = new[] { "distinguishedname", "objectGUID", "memberof" };
        private int pageSize = 1000;
        private string uniqueObjectIdentifierAttribute = "objectGUID";
        private bool includeObjectOwnerInfo = false;
        private bool enforceDomainScope = true;

        public string SearchBaseDN
        {
            get
            {
                return searchBaseDN;
            }

            set
            {
                searchBaseDN = value;
            }
        }

        public string SearchFilter
        {
            get
            {
                return searchFilter;
            }

            set
            {
                searchFilter = value;
            }
        }

        public int PageSize
        {
            get
            {
                return pageSize;
            }

            set
            {
                pageSize = value;
            }
        }

        public string UniqueObjectIdentifierAttribute
        {
            get
            {
                return  uniqueObjectIdentifierAttribute;
            } 
            
            set
            {
                uniqueObjectIdentifierAttribute = value;
            }
        }

        public bool IncludeObjectOwnerInfo
        {
            get { return includeObjectOwnerInfo; }
            set { includeObjectOwnerInfo = value; }
        }

        public bool IsDomainScopeEnforced
        {
            get { return enforceDomainScope; }
            set { enforceDomainScope = value; }
        }

        public string[] AttributesToLoad
        {
            get
            {
                if (!attributesToLoad.Contains(UniqueObjectIdentifierAttribute, StringComparer.OrdinalIgnoreCase))
                {
                    Array.Resize(ref attributesToLoad, attributesToLoad.Length + 1);
                    attributesToLoad[attributesToLoad.Length - 1] = UniqueObjectIdentifierAttribute;
                }

                return attributesToLoad;
            }

            set
            {
                attributesToLoad = value;
            }
        }
    }
}
